// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class STAFF_RSP_K25 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("10 STF",10)]
  	    [HL7Field(HL7Version.v24, 10, HL7Repeat.False, HL7Required.True,"STF")]
	    public STF STF {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("12 PRA",12)]
  	    [HL7Field(HL7Version.v24, 12, HL7Repeat.False, HL7Required.False,"PRA")]
	    public PRA PRA {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("16 ORG",16)]
  	    [HL7Field(HL7Version.v24, 16, HL7Repeat.True, HL7Required.False,"ORG")]
	    public ORG[] ORG {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("21 AFF",21)]
  	    [HL7Field(HL7Version.v24, 21, HL7Repeat.True, HL7Required.False,"AFF")]
	    public AFF[] AFF {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("26 LAN",26)]
  	    [HL7Field(HL7Version.v24, 26, HL7Repeat.True, HL7Required.False,"LAN")]
	    public LAN[] LAN {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("31 EDU",31)]
  	    [HL7Field(HL7Version.v24, 31, HL7Repeat.True, HL7Required.False,"EDU")]
	    public EDU[] EDU {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			STF = PopSegmentParseAndCheckRequired<STF>(availableData, options, "STF");
			PRA = PopSegmentParseAndCheckRequired<PRA>(availableData, options, "PRA");
			ORG = PopSegmentParseAndCheckRequiredArray<ORG>(availableData, options, "ORG");
			AFF = PopSegmentParseAndCheckRequiredArray<AFF>(availableData, options, "AFF");
			LAN = PopSegmentParseAndCheckRequiredArray<LAN>(availableData, options, "LAN");
			EDU = PopSegmentParseAndCheckRequiredArray<EDU>(availableData, options, "EDU");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isSTF = availableData.StartsWith("STF", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("STF", options.Version) || isSTF) {
				return isSTF;
			}
			bool isPRA = availableData.StartsWith("PRA", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("PRA", options.Version) || isPRA) {
				return isPRA;
			}
			bool isORG = availableData.StartsWith("ORG", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("ORG", options.Version) || isORG) {
				return isORG;
			}
			bool isAFF = availableData.StartsWith("AFF", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("AFF", options.Version) || isAFF) {
				return isAFF;
			}
			bool isLAN = availableData.StartsWith("LAN", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("LAN", options.Version) || isLAN) {
				return isLAN;
			}
			bool isEDU = availableData.StartsWith("EDU", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("EDU", options.Version) || isEDU) {
				return isEDU;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "STAFF";
			}
        }

        static STAFF_RSP_K25() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(STAFF_RSP_K25));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (STF != null) {
			string segmentValue = STF.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (PRA != null) {
			string segmentValue = PRA.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (ORG != null && ORG.Length > 0) {
			for (int i = 0; i < ORG.Length; i++) {
				string segmentValue = ORG[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
		 if (AFF != null && AFF.Length > 0) {
			for (int i = 0; i < AFF.Length; i++) {
				string segmentValue = AFF[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
		 if (LAN != null && LAN.Length > 0) {
			for (int i = 0; i < LAN.Length; i++) {
				string segmentValue = LAN[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
		 if (EDU != null && EDU.Length > 0) {
			for (int i = 0; i < EDU.Length; i++) {
				string segmentValue = EDU[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

